<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<style>
    .el-input-item {
        width: 260px;
    }

</style>
<div id="app">
    <template>
        <el-form :model="formData" ref="formData" :rules="rules" label-width="100px"
                 style="margin-top: 5%;display: flex;flex-direction: row;align-items: center;flex-wrap: wrap;justify-content: space-between;margin-right: 5%">
            <el-form-item label="名称" prop="name">
                <el-input class="el-input-item" size="small" v-model="formData.name" placeholder="请输入名称"/>
            </el-form-item>
            <el-form-item label="endpoint" prop="endpoint">
                <el-input class="el-input-item" size="small" v-model="formData.endpoint" placeholder="请输入endpoint"/>
            </el-form-item>
            <el-form-item label="access_key" prop="accessKey">
                <el-input class="el-input-item" size="small" v-model="formData.accessKey" placeholder="请输入access_key"/>
            </el-form-item>
            <el-form-item label="secret_key" prop="secretKey">
                <el-input class="el-input-item" size="small" v-model="formData.secretKey" placeholder="请输入secret_key"/>
            </el-form-item>
            <el-form-item label="bucket_Name" prop="bucketName">
                <el-input class="el-input-item" size="small" v-model="formData.bucketName"
                          placeholder="请输入bucket_Name"/>
            </el-form-item>
        </el-form>
        <div style="text-align: center;margin-top: 5%">
            <el-button size="small" @click="closePage">取 消</el-button>
            <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
        </div>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/api/sysOss.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    let id = getQueryString("id");
    new Vue({
        el: '#app',
        data() {
            return {
                formData: {},

                // 创建时间字典
                createTimeOptions: [],
                rules: {
                    name: [
                        {required: true, message: "名称不能为空", trigger: "blur"}
                    ],
                    endpoint: [
                        {required: true, message: "endpoint不能为空", trigger: "blur"}
                    ],
                    accessKey: [
                        {required: true, message: "access_key不能为空", trigger: "blur"}
                    ],
                    secretKey: [
                        {required: true, message: "secret_key不能为空", trigger: "blur"}
                    ],
                    bucketName: [
                        {required: true, message: "bucket_Name不能为空", trigger: "blur"}
                    ],
                    createTime: [
                        {required: true, message: "创建时间不能为空", trigger: "blur"}
                    ]
                }
            }
        },
        created() {
            if (id) {
                detail(id).then((res) => {
                    if (res.code === '200') {
                        this.formData = res.data
                    }
                });
            } else {
                this.formData = {}
            }


        },
        methods: {
            handleSubmit() {
                if (id) {
                    addOrUpdate('/admin/sysOss/update', this);
                } else {
                    addOrUpdate('/admin/sysOss/add', this);
                }
            }
        }
    });
</script>
</html>
